﻿using UnityEngine;
using Yoozoo.Gameplay.RTS;

namespace Yoozoo.Gameplay.City
{
    public class CityRealAiNpcAnimatorEventController : MonoBehaviour, GPUSkinning_IAnimationEventReceiver
    {
        public delegate void TriggerFixedDelegate();
        public event TriggerFixedDelegate OnTriggerFixed;
        
        public delegate void BindBoneDelegate(int skeletonPoint);
        public event BindBoneDelegate OnBindBone;
        
        public delegate void AddItemDelegate();
        public event AddItemDelegate OnAddItem;
        
        public delegate void GetItemDelegate();
        public event GetItemDelegate OnGetItem;
        
        public delegate void PutDownItemDelegate();
        public event PutDownItemDelegate OnPutDownItem;
        
        public delegate void DeleteItemDelegate();
        public event DeleteItemDelegate OnDeleteItem;

        public delegate void ShowBubbleDelegate();

        public event ShowBubbleDelegate OnShowBubble;

        public delegate void HideBubbleDelegate();

        public event HideBubbleDelegate OnHideBubble;

        public delegate void OnTriggerEffectDelegate();

        public event OnTriggerEffectDelegate OnTriggerEffect;
        
        public void SendAniEventMessage(string functionName)
        {
            switch (functionName)
            {
                case "TriggerFixed":
                    TriggerFixed();
                    break;
                case "AddItem":
                    AddItem();
                    break;
                case "GetItem":
                    GetItem();
                    break;
                case "PutDownItem":
                    PutDownItem();
                    break;
                case "DeleteItem":
                    DeleteItem();
                    break;
                case "ShowBubble":
                    ShowBubble();
                    break;
                case "HideBubble":
                    HideBubble();
                    break;
                case "TriggerEffect":
                    TriggerEffect();
                    break;
            }
        }

        public void SendAniEventMessage(string functionName, int param)
        {
            switch (functionName)
            {
                case "BindBone":
                    BindBone(param);
                    break;
                default:
                    SendAniEventMessage(functionName);
                    break;
            }
        }
        
        //触发固定物体动画
        public void TriggerFixed()
        {
            if (OnTriggerFixed != null)
            {
                OnTriggerFixed.Invoke();
            }
        }

        //动画事件预绑定道具骨骼点
        public void BindBone(int skeletonPoint)
        {
            if (OnBindBone != null)
            {
                OnBindBone.Invoke(skeletonPoint);
            }
        }
        
        //添加交互道具（钱、盘子之类的）
        public void AddItem()
        {
            if (OnAddItem != null)
            {
                OnAddItem.Invoke();
            }
        }
        
        //拿起交互道具
        public void GetItem()
        {
            if (OnGetItem != null)
            {
                OnGetItem.Invoke();
            }
        }
        
        //放下交互道具
        public void PutDownItem()
        {
            if (OnPutDownItem != null)
            {
                OnPutDownItem.Invoke();
            }
        }
        
        //删除交互道具
        public void DeleteItem()
        {
            if (OnDeleteItem != null)
            {
                OnDeleteItem.Invoke();
            }
        }

        public void ShowBubble()
        {
            if (OnShowBubble != null)
            {
                OnShowBubble.Invoke();
            }
        }

        public void HideBubble()
        {
            if (OnHideBubble != null)
            {
                OnHideBubble.Invoke();
            }
        }

        public void TriggerEffect()
        {
            if (OnTriggerEffect != null)
            {
                OnTriggerEffect.Invoke();
            }
        }
    }
}
